home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha Extra 2004 January / CyberMycha Extra 1-2004 (Poland) (Disc 2).bin / Pippi / gmgs.dir / Internal_5_gsScript.ls < prev    next >
Encoding:
Text File  |  2001-09-05  |  9.2 KB  |  382 lines

  1. property horseSprite, horseSprites, thingSprites, grassSprites, sprites, thingsOn, stopSprite, stopped, leftSideSprite, rightSideSprite, riverSprite, fenceSprite, whichHorse, speed, overAllSpeed, jumpTime, leftStop, rightStop, horseSideRect, dontTrig, backCounter, horsR, horsL, horsV, startTime, runTime, tiredHorse, backIsOK, randTrigNum, DirectTrig, dontTrigFor, JumpSprites, StopSprites, StopSymbolCounter, JumpSymbolCounter
  2.  
  3. on new me
  4.   overAllSpeed = 0
  5.   horsR = 565
  6.   horsL = 240
  7.   horsV = 395
  8.   StopSymbolCounter = 0
  9.   JumpSymbolCounter = 0
  10.   JumpSprites = []
  11.   StopSprites = []
  12.   return me
  13. end
  14.  
  15. on initGame me
  16.   backIsOK = 1
  17.   tiredHorse = 0
  18.   backCounter = 25
  19.   overAllSpeed = overAllSpeed + 1
  20.   speed = overAllSpeed
  21.   startTime = the ticks
  22.   thingsOn = []
  23.   horseSprites = []
  24.   thingSprites = []
  25.   grassSprites = []
  26.   randTrigNum = 0
  27.   DirectTrig = 0
  28.   dontTrigFor = 0
  29.   stopped = 0
  30.   dontTrig = 0
  31. end
  32.  
  33. on checkOtherZeroJumpables me, pSprite
  34.   v = 1
  35.   if thingsOn.count > 0 then
  36.     repeat with n = 1 to thingsOn.count
  37.       if thingsOn[n].jumpable = 0 then
  38.         if pSprite <> thingsOn[n] then
  39.           v = 0
  40.           exit repeat
  41.         end if
  42.       end if
  43.     end repeat
  44.   end if
  45.   return v
  46. end
  47.  
  48. on trigThings me
  49.   if speed > 0 then
  50.     runTime = the ticks - startTime
  51.     if runTime > 4500 then
  52.       if dontTrig = 1 then
  53.         if thingsOn.count = 1 then
  54.           dontTrig = 2
  55.           setOn(thingsOn[1])
  56.         end if
  57.         exit
  58.       else
  59.         if dontTrig = 0 then
  60.           dontTrig = 1
  61.           if overAllSpeed = 1 then
  62.             thingsOn[thingsOn.count + 1] = riverSprite
  63.           else
  64.             if overAllSpeed = 2 then
  65.               thingsOn[thingsOn.count + 1] = fenceSprite
  66.             end if
  67.           end if
  68.           exit
  69.         else
  70.           exit
  71.         end if
  72.       end if
  73.     else
  74.       if DirectTrig = randTrigNum then
  75.         if dontTrigFor < 1 then
  76.           randTrigNum = random(2)
  77.           DirectTrig = random(randTrigNum)
  78.           trig(me, 1, DirectTrig)
  79.         else
  80.           dontTrigFor = dontTrigFor - 1
  81.         end if
  82.       else
  83.         trig(me, DirectTrig + 1, randTrigNum)
  84.         DirectTrig = randTrigNum
  85.         dontTrigFor = 1
  86.       end if
  87.     end if
  88.   end if
  89. end
  90.  
  91. on trig me, pNum1, pNum2
  92.   repeat with n = pNum1 to pNum2
  93.     numb = random(sprites.count)
  94.     thingsOn[thingsOn.count + 1] = sprites[numb]
  95.     sprites[numb].setOn(randTrigNum, n)
  96.     sprites.deleteAt(numb)
  97.   end repeat
  98. end
  99.  
  100. on reCoverThing me, pSprite
  101.   thingsOn.deleteOne(pSprite)
  102.   sprites[sprites.count + 1] = pSprite
  103. end
  104.  
  105. on deCoverThing me, pSprite
  106.   thingsOn.deleteOne(pSprite)
  107. end
  108.  
  109. on lookUpBack me, pLoc
  110.   backLoc = pLoc + point(0, 120)
  111.   repeat with n = 1 to thingsOn.count
  112.     baseRect = thingsOn[n].rect
  113.     if inside(backLoc, baseRect) or inside(backLoc + point(-20, 0), baseRect) then
  114.       if thingsOn[n].loc[2] > backLoc[2] then
  115.         thingsOn[n].locZup()
  116.         next repeat
  117.       end if
  118.       stopped = 0
  119.       changeHorse(me, 1)
  120.       exit repeat
  121.     end if
  122.   end repeat
  123.   checkSides(me, pLoc)
  124. end
  125.  
  126. on checkSides me, pLoc
  127.   if leftStop = 1 then
  128.     horseSideRect = rect(pLoc[1] - 30, pLoc[2] - 50, pLoc[1] + 30, pLoc[2] + 70)
  129.     if intersect(horseSideRect, rect(leftSideSprite.rect[1], leftSideSprite.loc[2], leftSideSprite.rect[3], leftSideSprite.rect[4])) > rect(0, 0, 0, 0) = 0 then
  130.       leftStop = 0
  131.     end if
  132.   end if
  133.   if rightStop = 1 then
  134.     horseSideRect = rect(pLoc[1] - 30, pLoc[2] - 50, pLoc[1] + 30, pLoc[2] + 70)
  135.     if intersect(horseSideRect, rect(rightSideSprite.rect[1], rightSideSprite.loc[2], rightSideSprite.rect[3], rightSideSprite.rect[4])) > rect(0, 0, 0, 0) = 0 then
  136.       rightStop = 0
  137.     end if
  138.   end if
  139. end
  140.  
  141. on lookup me, pLoc
  142.   horseFrontRect = rect(pLoc[1] + 20, pLoc[2] - 65, pLoc[1] + 25, pLoc[2] - 60)
  143.   horseSideRect = rect(pLoc[1] - 30, pLoc[2] - 50, pLoc[1] + 30, pLoc[2] + 70)
  144.   backLoc = pLoc + point(0, 60)
  145.   if thingsOn.count > 0 then
  146.     repeat with n = 1 to thingsOn.count
  147.       baseRect = thingsOn[n].rect
  148.       if intersect(horseFrontRect, baseRect) > rect(0, 0, 0, 0) then
  149.         if ((the frameLabel = "h2") and (thingsOn[n].jumpable = 0)) or (the frameLabel <> "h2") then
  150.           if thingsOn[n].loc[2] > backLoc[2] then
  151.             thingsOn[n].locZup()
  152.           else
  153.             thingsOn[n].locZdown()
  154.             if speed > 0 then
  155.               stopped = 1
  156.               stopSprite = thingsOn[n]
  157.               changeHorse(me, 4)
  158.               exit repeat
  159.             end if
  160.           end if
  161.         end if
  162.       end if
  163.       if the frameLabel <> "h2" then
  164.         if intersect(horseSideRect, baseRect) > rect(0, 0, 0, 0) then
  165.           if thingsOn[n].locH < pLoc[1] then
  166.             if leftStop = 0 then
  167.               if thingsOn[n].loc[2] > backLoc[2] then
  168.                 thingsOn[n].locZup()
  169.               else
  170.                 thingsOn[n].locZdown()
  171.                 leftSideSprite = thingsOn[n]
  172.                 leftStop = 1
  173.               end if
  174.             end if
  175.             next repeat
  176.           end if
  177.           if rightStop = 0 then
  178.             if thingsOn[n].loc[2] > backLoc[2] then
  179.               thingsOn[n].locZup()
  180.               next repeat
  181.             end if
  182.             thingsOn[n].locZdown()
  183.             rightSideSprite = thingsOn[n]
  184.             rightStop = 1
  185.           end if
  186.         end if
  187.       end if
  188.     end repeat
  189.     if stopped = 1 then
  190.       if intersect(horseFrontRect, stopSprite.rect) < rect(1, 1, 1, 1) then
  191.         stopped = 0
  192.         changeHorse(me, 5)
  193.       end if
  194.     end if
  195.     checkSides(me, pLoc)
  196.   end if
  197. end
  198.  
  199. on intersectTest me, pRect, pSprite
  200.   repeat with n = 1 to thingsOn.count
  201.     if intersect(thingsOn[n].rect + rect(0, -20, 0, 0), pRect) <> rect(0, 0, 0, 0) then
  202.       if pSprite <> thingsOn[n] then
  203.         return 1
  204.         exit
  205.       end if
  206.     end if
  207.   end repeat
  208.   return 0
  209. end
  210.  
  211. on intersectTestX me, pRect, pSprite
  212.   repeat with n = 1 to thingsOn.count
  213.     if intersect(thingsOn[n].rect + rect(0, -100, 0, 0), pRect) <> rect(0, 0, 0, 0) then
  214.       if pSprite <> thingsOn[n] then
  215.         return 1
  216.         exit
  217.       end if
  218.     end if
  219.   end repeat
  220.   return 0
  221. end
  222.  
  223. on intersectTestJump me, pRect, pSprite
  224.   repeat with n = 1 to thingsOn.count
  225.     if intersect(thingsOn[n].rect, pRect) <> rect(0, 0, 0, 0) then
  226.       if pSprite <> thingsOn[n] then
  227.         return 1
  228.         exit
  229.       end if
  230.     end if
  231.   end repeat
  232.   return 0
  233. end
  234.  
  235. on initSpriteList me
  236.   sprites = []
  237.   repeat with n = 1 to thingSprites.count
  238.     sprites[n] = thingSprites[n]
  239.   end repeat
  240.   thingsOn = []
  241. end
  242.  
  243. on setSpeedThings me
  244.   if thingsOn.count > 0 then
  245.     repeat with n = 1 to thingsOn.count
  246.       thingsOn[n].setSpeed()
  247.     end repeat
  248.     repeat with n = 1 to grassSprites.count
  249.       grassSprites[n].setSpeed()
  250.     end repeat
  251.   end if
  252. end
  253.  
  254. on goBack me
  255.   if the frameLabel <> "h6" then
  256.     changeHorse(me, 6)
  257.   end if
  258. end
  259.  
  260. on changeHorse me, p
  261.   case p of
  262.     1:
  263.       speed = 1 * overAllSpeed
  264.       setSpeedThings(me)
  265.     2:
  266.       jumpTime = the ticks + (70 / overAllSpeed)
  267.     4:
  268.       speed = 0
  269.       setSpeedThings(me)
  270.     6:
  271.       speed = -3
  272.       setSpeedThings(me)
  273.   end case
  274.   whichHorse = p
  275.   horsH = horseSprite.locH
  276.   horseSprite = horseSprites[whichHorse]
  277.   repeat with n = 1 to horseSprites.count
  278.     horseSprites[n].locV = 1000
  279.     horseSprites[n].static = 1
  280.   end repeat
  281.   horseSprite.locV = horsV
  282.   horseSprite.locH = horsH
  283.   horseSprite.static = 0
  284.   go("h" & string(p))
  285. end
  286.  
  287. on reportHorse me, pSprite
  288.   horseSprites[horseSprites.count + 1] = sprite(pSprite)
  289.   if horseSprite = VOID then
  290.     horseSprite = horseSprites[1]
  291.   end if
  292. end
  293.  
  294. on reportThing me, pSprite
  295.   thingSprites[thingSprites.count + 1] = sprite(pSprite)
  296. end
  297.  
  298. on reportGrass me, pSprite
  299.   grassSprites[grassSprites.count + 1] = sprite(pSprite)
  300. end
  301.  
  302. on reportStopSprite me, pSprite
  303.   StopSprites[StopSprites.count + 1] = pSprite
  304. end
  305.  
  306. on reportJumpSprite me, pSprite
  307.   JumpSprites[JumpSprites.count + 1] = pSprite
  308. end
  309.  
  310. on makeStopSymbol me
  311.   StopSymbolCounter = StopSymbolCounter + 1
  312.   if StopSymbolCounter < 13 then
  313.     spriteN = (StopSymbolCounter + 2) / 3
  314.     StopSprites[spriteN].hitShoe()
  315.     if StopSymbolCounter = 12 then
  316.       tiredHorse = 1
  317.     end if
  318.   end if
  319. end
  320.  
  321. on makeJumpSymbol me
  322.   if JumpSymbolCounter < JumpSprites.count then
  323.     JumpSymbolCounter = JumpSymbolCounter + 1
  324.     JumpSprites[JumpSymbolCounter].sugar()
  325.   end if
  326. end
  327.  
  328. on mouseHX me, pM
  329.   if (horseSprite.locH + pM) > horsR then
  330.     horseSprite.loc = point(horsR, horsV)
  331.   else
  332.     if (horseSprite.locH + pM) < horsL then
  333.       horseSprite.loc = point(horsL, horsV)
  334.     else
  335.       if (rightStop = 0) and (leftStop = 0) then
  336.         horseSprite.loc = horseSprite.loc + point(pM, 0)
  337.       else
  338.         if rightStop = 1 then
  339.           if pM < 0 then
  340.             horseSprite.loc = horseSprite.loc + point(pM, 0)
  341.           end if
  342.         end if
  343.         if leftStop = 1 then
  344.           if pM > 0 then
  345.             horseSprite.loc = horseSprite.loc + point(pM, 0)
  346.           end if
  347.         end if
  348.       end if
  349.     end if
  350.   end if
  351. end
  352.  
  353. on keyHit me
  354.   if the frameLabel <> 0 then
  355.     v = (the frameLabel).char[1]
  356.     if v = "h" then
  357.       case the keyCode of
  358.         49:
  359.           if the frameLabel = "h1" then
  360.             me.jump()
  361.           end if
  362.         123:
  363.           me.mouseHX(-20)
  364.         124:
  365.           me.mouseHX(20)
  366.       end case
  367.     end if
  368.   end if
  369. end
  370.  
  371. on jump me
  372.   changeHorse(me, 2)
  373. end
  374.  
  375. on leftX me
  376.   mouseHX(me, -40)
  377. end
  378.  
  379. on rightX me
  380.   mouseHX(me, 40)
  381. end
  382.